﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TvViewer.settings;
using System.Configuration;
using System.Xml.Linq;

namespace TvViewer
{
    public class Util
    {
        public static bool ChangeSettingsValue(String _file, String _setting, String _newValue)
        {
            try
            {
                XElement root = XElement.Load(_file);
                XElement xe =
                    (from el in root.Descendants("setting")
                     where el.Attribute("name").Value.Equals(_setting)
                     select el).First();

                xe.Element("value").Value = _newValue;
                root.Save(_file);

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        public static string CreateWebServiceUrl(String _server, String _port)
        {
            return "http://" + _server + ":" + _port + "/TvServiceWebServices.asmx";
        }
    }
}
